﻿Imports Telerik.Web.UI

Partial Class Bank
    Inherits System.Web.UI.Page

    Dim _CommandName As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim _lblPageTitle As Label
            _lblPageTitle = Me.Master.FindControl("lblPageTitle")
            _lblPageTitle.Text = GetLocalResourceObject("PageTitle")
        End If
    End Sub

    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Me.Theme = GetGlobalResourceObject("SystemResource", "Theme")
    End Sub

    Protected Sub rgBank_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgBank.ItemCommand
        If e.CommandName = "RowClick" AndAlso TypeOf e.Item Is GridDataItem Then
            e.Item.Selected = True
            Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
            hdnBankID.Value = dataItem.GetDataKeyValue("BankID").ToString
            rgBankAccounts.Rebind()
        End If

    End Sub

    Protected Sub rgBankAccounts_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgBankAccounts.ItemCommand
        _CommandName = e.CommandName
    End Sub


    Protected Sub rgBankAccounts_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgBankAccounts.ItemDataBound
        If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) And _CommandName <> "InitInsert" Then
            Dim editFormItem As GridEditFormItem = CType(e.Item, GridEditFormItem)
            Dim parentItem As GridDataItem = editFormItem.ParentItem

            Dim box As RadComboBox = CType(editFormItem.FindControl("rcbBank").FindControl("rcbd"), RadComboBox)
            'box.SelectedValue = parentItem("BankID").Text
            box.SelectedValue = hdnBankID.Value

            Dim box2 As RadComboBox = CType(editFormItem.FindControl("rcbAccountType").FindControl("rcbd"), RadComboBox)
            box2.SelectedValue = parentItem("AccountType_ID").Text

        End If

    End Sub

End Class

